#include <vector>
#include <iostream>

using namespace std;

class Solution {
private:
    int find_min(vector<int>& nums, int begin, int end) {
        if (begin == end) {
            return nums[begin];
        }
        while (1) {
            if (end - begin == 1) {
                return min(nums[end], nums[begin]);
            }
            int middle = (begin + end) / 2;
            if (nums[middle] > nums[end]) {
                begin = middle;
            } else if (nums[begin] > nums[middle]) {
                end = middle;
            } else if (nums[middle] == nums[end]) {
                if (nums[begin] == nums[middle]) {
                    return min(find_min(nums, begin, middle), find_min(nums, middle, end));
                } else {
                    return nums[begin];
                }
            } else {
                end = middle;
            }
        }
    }
public:
    int findMin(vector<int>& nums) {
        if (nums.size() == 0) {
            return 0;
        }
        return find_min(nums, 0, nums.size() - 1);
    }
};

int main() {
    vector<int> input = {1, 3, 5};
    Solution solution;
    int output = solution.findMin(input);
    cout << output << endl;
    return 0;
}

